<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateHkDeviceTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('hk_device', function (Blueprint $table) {
            $table->engine = 'Innodb';
            $table->comment('海康设备列表');
            $table->string('device_id', 64)->nullable(false)->comment('海康设备device_id');
            $table->string('device_model', 64)->nullable(false)->comment('设备型号');
            $table->string('device_name', 64)->nullable(false)->comment('设备名称');
            $table->string('device_serial', 64)->nullable(false)->comment('设备序列号');
            $table->unsignedTinyInteger('device_status')->nullable(false)->comment('设备状态 0：离线 1：在线');
            $table->string('group_id', 64)->nullable(false)->comment('海康设备分组id');
            $table->unsignedTinyInteger('is_encrypt')->nullable(false)->comment('设备加密状态：0-关闭，1-开启');
            $table->string('device_version', 64)->nullable(false)->comment('设备固件版本号');
            $table->unsignedTinyInteger('defence')->nullable()->comment('具有防护能力设备布撤防状态：0-睡眠，8-在家，16-外出，普通IPC设备布撤防状态：0-撤防，1-布防');
            $table->primary('device_id');
            $table->index('device_serial');
            $table->index('group_id');
            $table->datetimes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('hk_device');
    }
}
